﻿@{
    var gridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSize;
}

@using Spotshub.Plugin.Payments.GlobalPayments.Models;
@using Nop.Web.Framework;
@using Telerik.Web.Mvc.UI;
@using Nop.Core.Infrastructure;

<table class="adminContent">
    <tr>
        <td>
            <br />
            <input type="submit" id="btnAddNew" name="btnAddNew" value="@T("Admin.Common.AddNew")" onclick="javascript:OpenWindow('@(Url.RouteUrl("Plugin.Payments.GlobalPayments.ProfileAdd"))    ', 800, 400, true); return false;" class="t-button" />
        </td>
    </tr>
    <tr>
        <td>
            @(Html.Telerik().Grid<ProfileModel>()
                      .Name("profile-grid")
                      .DataKeys(keys => keys.Add(x => x.Id).RouteKey("Id"))
                      .Columns(columns =>
                      {
                          columns.Bound(x => x.Store).ReadOnly();
                          columns.Bound(x => x.ProfileId).ReadOnly();
                          columns.Bound(x => x.ApiToken);
                          columns.Bound(x => x.Type);
                          columns.Bound(x => x.Id)
                              .Width(50)
                              .Centered()
                              .ClientTemplate("<input type='submit' value='" + @T("Admin.Common.Edit").Text + "' onclick=\"" + "javascript:OpenWindow('" + @Url.RouteUrl("Plugin.Payments.GlobalPayments.ProfileEdit") + "?id=<#= Id #>', 800, 400, true); return false;\" class='t-button' />")
                              .Title(T("Admin.Common.Edit").Text);
                          columns.Command(commands =>
                          {
                              commands.Delete().Text(T("Admin.Common.Delete").Text);
                          }).Title(T("Admin.Common.Delete").Text).Width(180);

                      })
                      .DataBinding(dataBinding =>
                      {
                          dataBinding.Ajax()
                              .Select("ProfileList", "PaymentGlobalPayments", new RouteValueDictionary() { { "Namespaces", "Spotshub.Plugin.Payments.GlobalPayments.Controllers" }, { "area", "" } })
                              .Delete("ProfileDelete", "PaymentGlobalPayments", new RouteValueDictionary() { { "Namespaces", "Spotshub.Plugin.Payments.GlobalPayments.Controllers" }, { "area", "" } });
                      })
                      .Pageable(settings => settings.PageSize(gridPageSize).Position(GridPagerPosition.Both))
                      .EnableCustomBinding(true))
        </td>
    </tr>
</table>
